<?php

namespace Platform\Models\Pay;

use Platform\Models\BaseModel;

class PayOrder extends BaseModel {

    const TABLE_NAME = 'pay_order';

    public function initialize() {
        parent::initialize();
        $this->setSource(self::TABLE_NAME);
    }

    private $id;
    private $orderNo;
    private $userId;
    private $objectType;
    private $objectId;
    private $cash;
    private $createTime;
    private $status;
    private $updateTime;
    private $userNickname;
    private $userImg;
    private $beUserNickname;
    private $beUserImg;
    private $beUserId;
    private $openId;

    public function getId() {
        return $this->id;
    }

    public function getOrderNo() {
        return $this->orderNo;
    }

    public function getUserId() {
        return $this->userId;
    }

    public function getObjectType() {
        return $this->objectType;
    }

    public function getObjectId() {
        return $this->objectId;
    }

    public function getCash() {
        return $this->cash;
    }

    public function getCreateTime() {
        return $this->createTime;
    }

    public function getStatus() {
        return $this->status;
    }

    public function getUpdateTime() {
        return $this->updateTime;
    }

    public function getUserNickname() {
        return $this->userNickname;
    }

    public function getUserImg() {
        return $this->userImg;
    }

    public function getBeUserNickname() {
        return $this->beUserNickname;
    }

    public function getBeUserImg() {
        return $this->beUserImg;
    }

    public function getBeUserId() {
        return $this->beUserId;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setOrderNo($orderNo) {
        $this->orderNo = $orderNo;
    }

    public function setUserId($userId) {
        $this->userId = $userId;
    }

    public function setObjectType($objectType) {
        $this->objectType = $objectType;
    }

    public function setObjectId($objectId) {
        $this->objectId = $objectId;
    }

    public function setCash($cash) {
        $this->cash = $cash;
    }

    public function setCreateTime($createTime) {
        $this->createTime = $createTime;
    }

    public function setStatus($status) {
        $this->status = $status;
    }

    public function setUpdateTime($updateTime) {
        $this->updateTime = $updateTime;
    }

    public function setUserNickname($userNickname) {
        $this->userNickname = $userNickname;
    }

    public function setUserImg($userImg) {
        $this->userImg = $userImg;
    }

    public function setBeUserNickname($beUserNickname) {
        $this->beUserNickname = $beUserNickname;
    }

    public function setBeUserImg($beUserImg) {
        $this->beUserImg = $beUserImg;
    }

    public function setBeUserId($beUserId) {
        $this->beUserId = $beUserId;
    }

    public function getOpenId() {
        return $this->openId;
    }

    public function setOpenId($openId) {
        $this->openId = $openId;
    }

    public function columnMap() {
        //列名 =》 属性名
        return [
            'id' => 'id',
            'order_no' => 'orderNo',
            'user_id' => 'userId',
            'object_type' => 'objectType',
            'object_id' => 'objectId',
            'cash' => 'cash',
            'create_time' => 'createTime',
            'status' => 'status',
            'update_time' => 'updateTime',
            'user_nickname' => 'userNickname',
            'user_img' => 'userImg',
            'be_user_nickname' => 'beUserNickname',
            'be_user_img' => 'beUserImg',
            'be_user_id' => 'beUserId',
            "open_id" => "openId",
        ];
    }

    /**
     * 获取一条加锁的数据
     * @param $id
     * @param $columns
     */
    public function getForUpdateDataById($id, $columns = '') {
        $query = [
            "conditions" => "$this->pk = :id:",
            "bind" => [
                "id" => $id
            ],
            "for_update" => true
        ];
        if ($columns) {
            $query['columns'] = $columns;
        }
        $data = self::findFirst($query);
        return $data;
    }

}
